import dayjs from 'dayjs';
import { downLoad, request } from '../../../request';

/** 获取网板类型下拉 */
export function getBoardTypeSelect() {
  return request({
    url: '/qms/scrscreen/scrscreenType/pageList',
    method: 'get',
    params: {
      pageSize: 999999,
      pageNum: 1
    }
  });
}

/** 获取网板仓位下拉 */
export function getBoardPositionSelect() {
  return request({
    url: '/qms/scrscreen/scrscreenLocation/pageList',
    method: 'get',
    params: {
      pageSize: 999999,
      pageNum: 1
    }
  });
}

/** 新增网板 */
export function addBoard(data: any) {
  return request({
    url: '/qms/scrscreen/screenInfo/add',
    method: 'post',
    data
  });
}

/** 修改网板 */
export function updateBoard(data: any) {
  return request({
    url: '/qms/scrscreen/screenInfo/updateById',
    method: 'post',
    data
  });
}

/** 删除网板 */
export function deleteBoard(data: any) {
  return request({
    url: '/qms/scrscreen/screenInfo/delete',
    method: 'post',
    data
  });
}

/* 网板报废 */
export function scrapBoard(data: any) {
  return request({
    url: '/qms//scrscreen/screenInfo/scrapList',
    method: 'post',
    data
  });
}

/** 导出 */
export function exportBoard(params: any) {
  downLoad({
    url: '/qms/scrscreen/screenInfo/export',
    params,
    fileName: `网板${params.state === '3' ? '报复' : '管理'}记录导出${dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`
  });
}

/** 获取使用工艺下拉 */
export function getTechnologySelect(moduleNo: string) {
  return request({
    url: '/qms/scrscreen/screenInfo/getTechListByModuleNo',
    method: 'get',
    params: {
      moduleNo
    }
  });
}
/** 获取未选择的网框 */
export function getUnSelectedFrame(params: any) {
  return request({
    url: '/qms/scrscreen/frame/unusedList',
    method: 'get',
    params
  });
}

/** 获取全部网框 */
export function getAllSelectedFrame() {
  return request({
    url: '/qms/scrscreen/frame/pageList',
    method: 'get',
    params: {
      pageSize: 999999,
      pageNum: 1
    }
  });
}

/** 领取网板 */
export function receiveBoard(data: any) {
  return request({
    url: '/qms/scrscreen/screenInfo/gainList',
    method: 'post',
    data
  });
}

/** 归还网板 */
export function returnBoard(data: any) {
  return request({
    url: '/qms/scrscreen/screenInfo/returnList',
    method: 'post',
    data
  });
}

/** 获取网仓位 */
export function getLocationList() {
  return request({
    url: `/qms/scrscreen/scrscreenLocation/list`,
    method: 'GET'
  });
}

/** 修改网板类型 */
export function updateBoardType(data: any) {
  return request({
    url: '/qms/scrscreen/scrscreenType/update',
    method: 'post',
    data
  });
}

/** 新增网板类型 */
export function addBoardType(data: any) {
  return request({
    url: '/qms/scrscreen/scrscreenType/add',
    method: 'post',
    data
  });
}

/** 删除网板类型 */
export function deleteBoardType(data: any) {
  return request({
    url: '/qms/scrscreen/scrscreenType/delete',
    method: 'post',
    data
  });
}
